#define _CRT_SECURE_NO_WARNINGS
#include "test.h"

bool isValid(char* s)
{
	ST st;
	STInit(&st);
	while (*s)
	{
		if (*s == '(' || *s == '[' || *s == '{')
		{
			STPush(&st, *s);
		}
		else
		{
			if (STEmpty(&st))
			{
				STDestroy(&st);
				return false;
			}
			char top = STTop(&st);
			if (*s == ')' && top != '(' || *s == ']' && top != '[' || *s == '}' && top != '{')
			{
				STDestroy(&st);
				return false;
			}
			STPop(&st);
		}
		s++;
	}
	if (!STEmpty(&st))
	{
		STDestroy(&st);
		return false;
	}
	return true;
}

int main()
{
	char s1[] = "(([]))";
	bool ret1=isValid(&s1);
	char s2[] = "(([}))";
	bool ret2 = isValid(&s2);
	char s3[] = "()[]()";
	bool ret3 = isValid(&s3);
	char s4[] = "({[]))";
	bool ret4 = isValid(&s4);
	return 0;
}